<template>
  <div class="header wrap">
    <div class="login_box">
      <img src="../assets/img/indexLogo.6f8ac4f0.png" alt="" />
    </div>
    <ul class="nav_box">
      <li
        :class="{ cur: $route.path == '/home' }"
        @click="$router.push('/home')"
      >
        首页
      </li>
      <li
        :class="{ cur: $route.path == '/goods' }"
        @click="$router.push('/goods')"
      >
        全部商品
      </li>
      <li
        :class="{ cur: $route.path == '/user' }"
        @click="$router.push('/user')"
      >
        个人中心
      </li>
      <li
        :class="{ cur: $route.path == '/order' }"
        @click="$router.push('/order')"
      >
        我的订单
      </li>
      <li
        :class="{ cur: $route.path == '/free' }"
        @click="$router.push('/free')"
      >
        专属福利
      </li>
    </ul>
    <div class="search_box">
      <input type="text" placeholder="请输入关键字" v-model="keyword" />
      <span>
        <img
          src="../assets/img/search.png"
          alt=""
          @click="search"
          style="cursor: pointer"
        />
      </span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      keyword: "",
    };
  },
  methods: {
    search() {
      this.$router.push("/goods?keyword=" + this.keyword);
      this.keyword = "";
      // bus.$emit("keyword", this.keyword);
    },
  },
};
</script>

<style lang="less" scoped>
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 118px;

  .nav_box {
    width: 500px;
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    font-weight: 500;
    color: #242b39;
    cursor: pointer;

    .cur {
      color: #0a328e;
      font-weight: 700;
    }
  }

  .search_box {
    display: flex;

    input {
      width: 214px;
      height: 40px;
      border: 1px solid #dedede;
      border-radius: 20px 0px 0px 20px;
      outline: none;
      padding-left: 20px;
      box-sizing: border-box;
    }
    span {
      width: 50px;
      height: 40px;
      background: #0a328e;
      border-radius: 0px 20px 20px 0px;
      text-align: center;
      line-height: 40px;
    }
  }
}
</style>